package com.laiketui.admin.store.controller.productClass;

import com.laiketui.admin.store.api.productClass.ProductClassService;
import com.laiketui.common.api.index.IndexDataService;
import com.laiketui.common.mapper.ProductClassMapper;
import com.laiketui.core.domain.Result;
import com.laiketui.domain.vo.MainVo;
import com.laiketui.domain.vo.index.IndexDataVo;
import com.laiketui.domain.vo.productClass.ProductClassVo;
import com.laiketui.root.annotation.HttpApiMethod;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页数据
 */
@Api(tags = "后台-商城后台商品分类管理")
@RestController
@RequestMapping("/admin/product/productClass")
public class ProductClassController {

    @Autowired
    private ProductClassService productClassService;

    @ApiOperation("查询分类详情")
    @RequestMapping("/selectInfo")
    @HttpApiMethod(apiKey = "admin.productClass.selectInfo")
    public Result selectInfo(ProductClassVo vo) {
        return Result.success(productClassService.selectInfo(vo));
    }

    @ApiOperation("查询分类数据列表")
    @RequestMapping("/selectList")
    @HttpApiMethod(apiKey = "admin.productClass.selectList")
    public Result selectList(MainVo vo) {
        return Result.success(productClassService.selectList(vo));
    }

    @ApiOperation("新增分类数据")
    @PostMapping("/insertProductClass")
    @HttpApiMethod(apiKey = "admin.productClass.insertProductClass")
    public Result insertIndexData(ProductClassVo vo) {
//        JSONObject object = JSONObject.parseObject(vo.getItems());
        productClassService.insertProductClass(vo);
        return Result.success();
    }

    @ApiOperation("修改分类数据")
    @RequestMapping("/updateProductClass")
    @HttpApiMethod(apiKey = "admin.productClass.updateProductClass")
    public Result updateIndexData(ProductClassVo vo) {
        productClassService.updateProductClass(vo);
        return Result.success();
    }

    @ApiOperation("删除分类数据")
    @RequestMapping("/deleteProductClass")
    @HttpApiMethod(apiKey = "admin.productClass.deleteProductClass")
    public Result deleteIndexData(ProductClassVo vo) {
        return Result.success(productClassService.deleteProductClass(vo));
    }

    @ApiOperation("分类上下架")
    @RequestMapping("/updateStatus")
    @HttpApiMethod(apiKey = "admin.productClass.updateStatus")
    public Result updateStatus(ProductClassVo vo) {
        return Result.success(productClassService.updateStatus(vo));
    }

}


